#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;
using int64 = int64_t;

int f, v, a[101][101], dp[101][101];

void print(int i, int j){
    if (j == 0)
        return;
    for (int k = j; k <= i; k++)
        if (dp[i][j] == dp[k - 1][j - 1] + a[j][k]){
            print(k - 1, j - 1);
            cout << k << " ";
            break;
        }
}

signed main()
{
    cin >> f >> v;
    for (int i = 1; i <= f; i++)
        for (int j = 1; j <= v; j++)
            cin >> a[i][j];
    for (int i = 1; i <= f; i++)
        dp[i][i] = a[i][i] + dp[i - 1][i - 1];
    for (int i = 1; i <= v; i++)
        for (int j = 1; j <= f; j++){
            dp[i][j] = -1e8;
            for (int k = j; k <= i; k++)
                dp[i][j] = max(dp[i][j], dp[k - 1][j - 1] + a[j][k]);
        }
    cout << dp[v][f] << endl;
    print(v, f);
    return 0;
}